home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / NETWORK.SWG / 0011_NETWARE User name.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-21  |  2KB  |  73 lines

  1. {
  2. From: NORBERT IGL
  3. Subj: Netware "User name"
  4.  
  5.  I need a way to get the current user name from the netware shell.
  6.  For instance, if I'm logged into server MYSERVER as user SUPERVISOR,
  7.  I need some way to get 'supervisor' as the user name.  (Kind of like
  8.  WHOAMI would return: You are user SUPERVISOR on server MYSERVER)
  9. }
  10.  
  11. uses dos;
  12.  
  13. function lStationNumber:byte;   { MY logical Station(connection)-Number }
  14. var   regs     : Registers;
  15. begin
  16.    regs.ah := $DC;
  17.    MsDos(regs );
  18.    lStationNumber := pcregs.al;
  19. end;
  20.  
  21. function GetUserName( Station: byte):String;
  22. Var
  23.   i               : byte;
  24.   Regs            : Registers;
  25.   name            : string[50];
  26.   Reply    : Record
  27.                 Filler1      : Array [1..8] of byte;
  28.                 ObjectName   : Array [1..48] of Byte;
  29.                 Filler2me    : Array [1..8] of Byte;
  30.              End;
  31.   Request : Record
  32.                PacketLen : Integer;
  33.                vFunc     : Byte;
  34.                ConnNb    : Byte;
  35.              End;
  36.  
  37. Begin
  38.   With Request do
  39.   begin
  40.     PacketLen := 2;
  41.     vFunc     := 22;
  42.     ConnNbm   := Station;
  43.   End;
  44.   Reply.ReturnLength := 62;
  45.   With Regs Do Begin
  46.     Ah := $e3;
  47.     Ds := Seg(Request);
  48.     Si := Ofs(Request);
  49.     Es := Seg(Reply);
  50.     Di := Ofs(Reply);
  51.   End;
  52.   MsDos(Reg);
  53.           {         1         2         3         4        }
  54.           {123456789012345678901234567890123456789012345678}
  55.   name := '                                                ';
  56.   If Regs.al = 0 Then with reply do
  57.   begin
  58.      move( objectName[1] , name[1], 48 );
  59.      i := pos(#0, name );
  60.      name[0] := char(i-1);
  61.   end;
  62. end;
  63.  
  64. [...]
  65.  
  66. var me : byte;
  67.  
  68. begin
  69.    me := lStationNumber;
  70.    writeln(' Hello, ', GetUserName( me ),
  71.            ' you''re hooked in on Station # ', me );
  72. end.
  73.